package com.liang.test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class ArrayReflect {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer> list = new ArrayList<>();

        list.add(12);

        Class aclass = ArrayList.class;
        Method add = aclass.getMethod("add", Object.class);
        add.invoke(list,"你好");

        System.out.println(list);
    }
}
